package adv6;

public class JoinThreadDemo {

	public static void main(String[] args) {
		Thread[] th = new Thread[4];
		for (int i = 1; i <= 4; i++) {
			th[i - 1] = new Thread1("线程-" + i);
			th[i - 1].start();
		}
		// main线程等待其他线程结束
		for (int i = 1; i <= 4; i++) {
			try {
				th[i - 1].join();
			} catch (InterruptedException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
		}
		System.out.println(Thread.currentThread().getName() + "主线程结束了");

	}

}
